package com.jk.service.impl;

import com.jk.dao.LogDao;
import com.jk.pojo.PostBean;
import com.jk.pojo.UserBean;
import com.jk.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 2 * @author lujintao
 * 3 * @description 类描述
 * 4 * @date 2021/11/16
 * 5 * @version </pre>
 * 6
 */
@Service
public class LogServiceImpl implements LogService {
    @Autowired
    private LogDao logDao;
    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public UserBean findUserId(String name) {
        return logDao.findUserId(name);
    }

    @Override
    public void addUser(UserBean w) {
        logDao.addUser(w);
    }

    @Override
    public List<UserBean> selectAdmin() {
        return logDao.selectAdmin();
    }

    @Override
    public List<PostBean> selectPort() {

        List<PostBean> post = redisTemplate.opsForList().range("post", 0, -1);
        return post;
    }

    @Override
    public void addPost(PostBean e) {
        redisTemplate.opsForList().leftPush("post",e);
    }
}
